package com.hotline.communication.service.impl;

import com.hotline.communication.mapper.PlayRecordMapper;
import com.hotline.communication.dto.PlayRecordDTO;
import com.hotline.communication.service.PlayRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Objects;


@Service
@Slf4j
public class PlayRecordServiceImpl implements PlayRecordService {

    @Resource
    private PlayRecordMapper playRecordMapper;


    @Override
    @Transactional
    public PlayRecordDTO selectOne(String orgId) {
        PlayRecordDTO playRecordDTO = playRecordMapper.selectOne(orgId);
        if(Objects.nonNull(playRecordDTO)){
            playRecordDTO.setState(1);
            playRecordMapper.update(playRecordDTO);
        }
        return playRecordDTO;
    }

    /**
     * 更新记录
     * @param playRecordDTO
     */
    @Override
    public void update(PlayRecordDTO playRecordDTO) {
        playRecordMapper.update(playRecordDTO);
    }
}
